]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
BluetoothStatus: don't pass NaNs to native functions
authorGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 2 Mar 2011 16:27:24 +0000 (17:27 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 13 Mar 2011 16:05:33 +0000 (17:05 +0100)
GJS complains when a NaN is passed in place of an integer, and
parseInt returns that from non numeric string. Pass a sentinel
that cancels the operation in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=642978

js/ui/status/bluetooth.js

index 2926f97390ac13b9739b5b58644b691d0ab0aad0..78859075cec5fee8c0905ced0dd83d221f26d263 100644 (file)
@@ -471,9 +471,15 @@ PinNotification.prototype = {
 
         this.connect('action-invoked', Lang.bind(this, function(self, action) {
             if (action == 'ok') {
-                if (this._numeric)
-                    this._applet.agent_reply_passkey(this._devicePath, parseInt(this._entry.text));
-                else
+                if (this._numeric) {
+                    let num = parseInt(this._entry.text);
+                    if (isNaN(num)) {
+                        // user reply was empty, or was invalid
+                        // cancel the operation
+                        num = -1;
+                    }
+                    this._applet.agent_reply_passkey(this._devicePath, num);
+                } else
                     this._applet.agent_reply_pincode(this._devicePath, this._entry.text);
             } else {
                 if (this._numeric)